home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
ISSUE09
/
CLINIC
/
LISTBOXU.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-02-18
|
2KB
|
68 lines
unit Listboxu;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Slistbox;
type
TForm1 = class(TForm)
SListbox1: TSListbox;
SListbox2: TSListbox;
procedure ListboxScroll(Sender: TObject; ScrollCode, Pos: Word);
procedure ListboxSelChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.ListboxScroll(Sender: TObject; ScrollCode, Pos: Word);
begin
if Sender = SListbox1 then
SListbox2.TopIndex := SListbox1.TopIndex
else
SListbox1.TopIndex := SListbox2.TopIndex;
end;
{$ifdef SIMPLE}
procedure TForm1.ListboxSelChange(Sender: TObject);
begin
ListboxScroll(Sender, 0, 0);
end;
{$else}
procedure TForm1.ListboxSelChange(Sender: TObject);
var
Loop: Word;
Src, Dest: TListbox;
begin
{ Set up Src and Dest as original and mimic }
Src := Sender as TListbox;
Dest := SListbox1;
if Src = Dest then
Dest := SListbox2;
with Src do
begin
{ Stop destination from flickering as we update it }
Dest.Items.BeginUpdate;
{ Make multi-selections match in both listboxes }
if Dest.MultiSelect then
for Loop := 0 to Pred(Items.Count) do
Dest.Selected[Loop] := Selected[Loop]
else
Dest.ItemIndex := ItemIndex;
Dest.TopIndex := TopIndex;
Dest.Items.EndUpdate;
end;
end;
{$endif}
end.